<template>
  <div class="one-param-metrics">
    <div class="param-name">
      <span>{{ param_name }}</span>
    </div>
    <div class="metrics">
      <div class="metric" v-for="(value, name, index) in metrics" :key="name">
        <span class="metric-name">
          {{ name.charAt(0).toUpperCase() + name.slice(1) }}:
          {{ value.toFixed(3) }}
        </span>
        <!--<span>{{ pdf_result[name] }}</span>-->
        <PDFBarChart :pdf="pdf_result[name]" :color="COLOR_PANEL[index]" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType } from 'vue'
import { Metrics, PDFResult } from '@/types/visualization/calculation'

import { COLOR_PANEL } from '@/components/vis-graph/figure/utils.ts'

import PDFBarChart from '@/components/vis-graph/figure/base/PDFBarChart.vue'

defineProps({
  param_name: {
    type: String,
    required: true,
  },
  metrics: {
    type: Object as PropType<Metrics>,
    required: true,
  },
  pdf_result: {
    type: Object as PropType<PDFResult>,
    required: true,
  },
})
</script>

<style scoped>
.one-param-metrics {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
}

.param-name {
  text-align: center;
  font-weight: bold;

  width: 6rem;
  display: flex;
  justify-content: center;
  align-items: center;

  border-radius: 1rem;
  background-color: #eeeeee;
}

.param-name span {
  display: inline-block;
  width: 5rem;
  word-wrap: break-word;
}

.metrics {
  margin-left: 1rem;
  width: 100%;
  padding: 0.7rem;
  display: flex;
  justify-content: space-around;
  text-align: center;

  border-radius: 1rem;
  border: 2px solid rgba(0, 0, 0, 0);
  transition: border 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.metrics:hover {
  border: 2px solid #e0e0e0;
}

.metric {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.metric-name {
  font-size: 1.2rem;
}
</style>
